'use strict';

const Controller = require('egg').Controller;

class SearchController extends Controller {
  //搜索用户
    async user() {
        this.ctx.validate({
            keyword: {
                type: "string",
                required: true,

                desc: "关键名",
            },
           
        });
        let keyword=this.ctx.request.body.keyword;
        const res=await this.app.model.User.findOne({
            where:{
                username:keyword
            },
            attributes:{
                exclude:["password"]
            }
        });

    this.ctx.apiSuccess(res,"ok",200)
  }
}

module.exports = SearchController;
